package search.dynamic;

import java.util.Vector;

import env.Tile;

public class node {

	private Tile key; //me
	private Vector<node> neighbors;
	private int score;
	private Tile pred;
	
	public node(Tile key) {
		this.key = key;
		this.neighbors = new Vector<node>();
		this.score = 0;
		this.pred = null;
	}
	
	public Tile getKey() {
		return key;
	}

	public void setKey(Tile key) {
		this.key = key;
	}

	public Vector<node> getNeighbors() {
		return neighbors;
	}

	public void setNeighbors(Vector<node> neighbors) {
		this.neighbors = neighbors;
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public Tile getPred() {
		return pred;
	}

	public void setPred(Tile pred) {
		this.pred = pred;
	}
	
	public boolean equals(Object o) {
		return (o instanceof node && this.key == ((node)o).getKey());
	}
	
	public void addNeighbor(node n) {
		if (n != null && !this.equals(n) && 
				!this.getNeighbors().contains(n.getKey()) &&
				!n.getNeighbors().contains(this.getKey()))
			this.neighbors.add(n);
	}
}
